package cn.iocoder.yudao.module.xkfz.controller.admin.excel;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.xkfz.domain.excel.entity.InventionPatent;
import cn.iocoder.yudao.module.xkfz.domain.excel.po.InventionPatentPO;
import cn.iocoder.yudao.module.xkfz.service.excel.InventionPatentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * @Description 专利
 * @Author ZWC
 * @Date 2024/6/25 10:17
 */
@RestController
@RequestMapping("inventionPatent")
public class InventionPatentController {

    @Autowired
    private InventionPatentService inventionPatentService;

    @PostMapping("importInventionPatent")
    public CommonResult<Boolean> importInventionPatent(@RequestParam("file") MultipartFile file, @RequestParam("year")  String year) throws IOException {
        List<InventionPatent> list = ExcelUtils.read(file, InventionPatent.class);
        return success(inventionPatentService.importInventionPatent(list, year));
    }

    @GetMapping("selectPage")
    public CommonResult<PageResult<InventionPatent>>  selectPage (InventionPatentPO reqVO){
        return success(inventionPatentService.selectPage(reqVO));
    }
    @PostMapping("insert")
    public CommonResult<Boolean> insert(InventionPatent inventionPatent){
        return success(inventionPatentService.insert(inventionPatent));
    }
    @PostMapping("update")
    public CommonResult<Boolean> update(InventionPatent inventionPatent){
        return success(inventionPatentService.update(inventionPatent));
    }

    @PostMapping("delete")
    public CommonResult<Boolean> delete(String id){
        return success(inventionPatentService.delete(id));
    }

}
